home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / Magic Text Scroll Java Applet Commercial v1.0 / magicsc2.exe / magic_textscroll.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-02-26  |  6.2 KB  |  282 lines

  1. import java.applet.Applet;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Event;
  5. import java.awt.Font;
  6. import java.awt.FontMetrics;
  7. import java.awt.Frame;
  8. import java.awt.Graphics;
  9. import java.awt.Image;
  10. import java.net.URL;
  11.  
  12. public class magic_textscroll extends Applet implements Runnable {
  13.    // $FF: renamed from: ru java.lang.Thread
  14.    Thread field_0;
  15.    // $FF: renamed from: tx java.lang.String[]
  16.    String[] field_1;
  17.    // $FF: renamed from: di java.lang.String[]
  18.    String[] field_2;
  19.    // $FF: renamed from: cy java.awt.Color[]
  20.    Color[] field_3;
  21.    // $FF: renamed from: yc int[]
  22.    int[] field_4;
  23.    // $FF: renamed from: nf java.awt.Font[]
  24.    Font[] field_5;
  25.    int[] txth;
  26.    int[] aralik;
  27.    int[] descdata;
  28.    // $FF: renamed from: wp int[]
  29.    int[] field_6;
  30.    int[] controld;
  31.    int[] animation_step;
  32.    // $FF: renamed from: og java.awt.Graphics
  33.    Graphics field_7;
  34.    Image img;
  35.    // $FF: renamed from: ge int
  36.    int field_8;
  37.    // $FF: renamed from: yu int
  38.    int field_9;
  39.    int text_count;
  40.    // $FF: renamed from: d int
  41.    int field_10;
  42.    // $FF: renamed from: X int[]
  43.    int[] field_11;
  44.    int[] mesajgenisligi;
  45.    FontMetrics fmetrics;
  46.    boolean ilk = true;
  47.    Color bgc;
  48.    long hiz;
  49.    String link1 = "";
  50.    String infostr = "";
  51.    String target_frame = "";
  52.    String regcode = "";
  53.    // $FF: renamed from: u java.net.URL
  54.    URL field_12;
  55.    int bgcolor;
  56.    int fgcolor;
  57.    // $FF: renamed from: rg boolean
  58.    boolean field_13 = false;
  59.    boolean whb = false;
  60.  
  61.    public void init() {
  62.       this.field_8 = -1;
  63.       this.field_9 = -1;
  64.       this.whb = false;
  65.       String var1 = "";
  66.       var1 = ((Applet)this).getParameter("bgcolor");
  67.  
  68.       try {
  69.          this.bgcolor = Integer.parseInt(var1, 16);
  70.       } catch (Exception var3) {
  71.          this.bgcolor = 0;
  72.       }
  73.  
  74.       this.bgc = new Color(this.bgcolor);
  75.       ((Component)this).setBackground(this.bgc);
  76.       this.regcode = ((Applet)this).getParameter("regcode");
  77.       if (this.regcode != null && this.regcode.equals("mtxscr34")) {
  78.          this.field_13 = true;
  79.       }
  80.  
  81.       try {
  82.          this.text_count = Integer.parseInt(((Applet)this).getParameter("text_count"), 10);
  83.       } catch (Exception var2) {
  84.          this.text_count = 0;
  85.       }
  86.  
  87.       this.infostr = ((Applet)this).getParameter("info");
  88.       this.hiz = Long.valueOf(((Applet)this).getParameter("delay_time"));
  89.       this.field_1 = new String[this.text_count + 1];
  90.       this.field_2 = new String[this.text_count + 1];
  91.       this.field_3 = new Color[this.text_count + 1];
  92.       this.field_4 = new int[this.text_count + 1];
  93.       this.field_5 = new Font[this.text_count + 1];
  94.       this.mesajgenisligi = new int[this.text_count + 1];
  95.       this.txth = new int[this.text_count + 1];
  96.       this.aralik = new int[this.text_count + 1];
  97.       this.descdata = new int[this.text_count + 1];
  98.       this.descdata = new int[this.text_count + 1];
  99.       this.field_11 = new int[this.text_count + 1];
  100.       this.field_6 = new int[this.text_count + 1];
  101.       this.controld = new int[this.text_count + 1];
  102.       this.animation_step = new int[this.text_count + 1];
  103.       this.link1 = ((Applet)this).getParameter("link");
  104.       this.target_frame = ((Applet)this).getParameter("target_frame");
  105.    }
  106.  
  107.    public boolean mouseEnter(Event var1, int var2, int var3) {
  108.       if (this.whb) {
  109.          this.stop();
  110.          if (this.link1 == null) {
  111.             return true;
  112.          }
  113.  
  114.          if (this.link1.equals("") || this.link1.equals(" ")) {
  115.             return true;
  116.          }
  117.  
  118.          ((Frame)((Component)this).getParent()).setCursor(12);
  119.          if (this.field_13) {
  120.             ((Applet)this).showStatus("" + this.link1);
  121.          } else {
  122.             ((Applet)this).showStatus("  Unregistered version of Magic Textscroll Java applet. URL: japplets.tripod.com");
  123.          }
  124.       }
  125.  
  126.       return true;
  127.    }
  128.  
  129.    public boolean mouseExit(Event var1, int var2, int var3) {
  130.       if (this.whb) {
  131.          ((Applet)this).showStatus("");
  132.          this.start();
  133.          ((Frame)((Component)this).getParent()).setCursor(0);
  134.       }
  135.  
  136.       return true;
  137.    }
  138.  
  139.    public boolean mouseDown(Event var1, int var2, int var3) {
  140.       if (this.whb) {
  141.          try {
  142.             this.field_12 = new URL("" + this.link1);
  143.             ((Applet)this).getAppletContext().showDocument(this.field_12, this.target_frame);
  144.          } catch (Exception var4) {
  145.             return true;
  146.          }
  147.       }
  148.  
  149.       return true;
  150.    }
  151.  
  152.    public void update(Graphics var1) {
  153.       if (this.whb) {
  154.          this.field_7.setColor(this.bgc);
  155.          this.field_7.fillRect(0, 0, this.field_8, this.field_9);
  156.  
  157.          for(this.field_10 = 1; this.field_10 <= this.text_count; ++this.field_10) {
  158.             this.field_7.setFont(this.field_5[this.field_10]);
  159.             this.field_7.setColor(this.field_3[this.field_10]);
  160.             this.field_7.drawString(this.field_1[this.field_10], this.field_11[this.field_10], this.txth[this.field_10] + this.aralik[this.field_10] - this.descdata[this.field_10]);
  161.             int var10002 = this.controld[this.field_10]++;
  162.             if (this.controld[this.field_10] > this.field_6[this.field_10]) {
  163.                this.controld[this.field_10] = 1;
  164.                if (this.field_2[this.field_10].equals("true")) {
  165.                   this.field_11[this.field_10] -= this.animation_step[this.field_10];
  166.                   if (this.field_11[this.field_10] < -this.mesajgenisligi[this.field_10]) {
  167.                      this.field_11[this.field_10] = this.field_8;
  168.                   }
  169.                } else {
  170.                   this.field_11[this.field_10] += this.animation_step[this.field_10];
  171.                   if (this.field_11[this.field_10] > this.field_8) {
  172.                      this.field_11[this.field_10] = -1 * this.mesajgenisligi[this.field_10];
  173.                   }
  174.                }
  175.             }
  176.          }
  177.  
  178.          this.paint(var1);
  179.       }
  180.  
  181.    }
  182.  
  183.    public void paint(Graphics var1) {
  184.       if (this.whb) {
  185.          var1.drawImage(this.img, 0, 0, this);
  186.       }
  187.  
  188.    }
  189.  
  190.    public void start() {
  191.       if (this.field_0 == null) {
  192.          this.field_0 = new Thread(this);
  193.          this.field_0.start();
  194.       }
  195.  
  196.    }
  197.  
  198.    public void stop() {
  199.       if (this.field_0 != null) {
  200.          this.field_0.stop();
  201.          this.field_0 = null;
  202.       }
  203.  
  204.    }
  205.  
  206.    public void run() {
  207.       ((Applet)this).showStatus("");
  208.       ((Component)this).show();
  209.       this.field_8 = ((Component)this).size().width;
  210.       this.field_9 = ((Component)this).size().height;
  211.       if (!this.whb) {
  212.          for(this.field_10 = 1; this.field_10 <= this.text_count; ++this.field_10) {
  213.             if (this.infostr != null) {
  214.                if (this.infostr.equals("Applet by Gokhan Dagli,japplets.tripod.com")) {
  215.                   this.field_1[this.field_10] = ((Applet)this).getParameter("text" + this.field_10);
  216.                } else {
  217.                   this.field_1[this.field_10] = "Warning ! info parameter error!";
  218.                }
  219.             } else {
  220.                this.field_1[this.field_10] = "Warning ! info parameter error!";
  221.             }
  222.  
  223.             try {
  224.                this.field_4[this.field_10] = Integer.parseInt(((Applet)this).getParameter("textcolor" + this.field_10), 16);
  225.             } catch (Exception var5) {
  226.                this.field_4[this.field_10] = 0;
  227.             }
  228.  
  229.             this.field_3[this.field_10] = new Color(this.field_4[this.field_10]);
  230.             this.field_2[this.field_10] = ((Applet)this).getParameter("direction" + this.field_10);
  231.  
  232.             try {
  233.                this.field_6[this.field_10] = Integer.parseInt(((Applet)this).getParameter("wait_period" + this.field_10), 10);
  234.             } catch (Exception var4) {
  235.                this.field_6[this.field_10] = 2;
  236.             }
  237.  
  238.             try {
  239.                this.animation_step[this.field_10] = Integer.parseInt(((Applet)this).getParameter("animation_step" + this.field_10), 10);
  240.             } catch (Exception var3) {
  241.                this.animation_step[this.field_10] = 2;
  242.             }
  243.  
  244.             try {
  245.                this.field_5[this.field_10] = new Font(((Applet)this).getParameter("font_type" + this.field_10), Integer.valueOf(((Applet)this).getParameter("font_style" + this.field_10)), Integer.valueOf(((Applet)this).getParameter("font_size" + this.field_10)));
  246.             } catch (Exception var2) {
  247.                this.field_5[this.field_10] = new Font("Arial", 0, 9);
  248.             }
  249.  
  250.             this.fmetrics = ((Component)this).getFontMetrics(this.field_5[this.field_10]);
  251.             this.mesajgenisligi[this.field_10] = this.fmetrics.stringWidth(this.field_1[this.field_10]);
  252.             this.descdata[this.field_10] = this.fmetrics.getDescent();
  253.             this.txth[this.field_10] = this.fmetrics.getDescent() + this.fmetrics.getAscent();
  254.             this.aralik[this.field_10] = (this.field_9 - this.txth[this.field_10]) / 2;
  255.             if (this.field_2[this.field_10].equals("true")) {
  256.                this.field_11[this.field_10] = this.field_8;
  257.             } else {
  258.                this.field_11[this.field_10] = -1 * this.mesajgenisligi[this.field_10];
  259.             }
  260.  
  261.             this.controld[this.field_10] = 0;
  262.          }
  263.  
  264.          this.img = ((Component)this).createImage(this.field_8, this.field_9);
  265.          this.field_7 = this.img.getGraphics();
  266.          this.field_7.setColor(this.bgc);
  267.          this.field_7.fillRect(0, 0, this.field_8, this.field_9);
  268.       }
  269.  
  270.       this.whb = true;
  271.  
  272.       while(true) {
  273.          try {
  274.             Thread.sleep(this.hiz);
  275.          } catch (InterruptedException var1) {
  276.          }
  277.  
  278.          ((Component)this).repaint();
  279.       }
  280.    }
  281. }
  282.